import numpy as np
import matplotlib.pyplot as plt
import os

fname = 'fig3d.npz'

# load npz file
data = np.load(fname, allow_pickle=True)
print(data.files)
B_up = data['B_up']
B_down = data['B_down']
Rxx_up = data['Rxx_up']
Rxx_down = data['Rxx_down']
B_lin = data['B_lin']
Rxx_sym = data['Rxx_sym']
Temperature = data['Temperature']
indices = data['indices']


# plot raw data
fig, ax = plt.subplots()
fig.suptitle('fig3d raw data')
for i in indices:
    ax.plot(B_up[:,i], Rxx_up[:, i], label='T = ' + str(Temperature[i]) + ' K')
    ax.plot(B_down[:,i], Rxx_down[:, i], label='T = ' + str(Temperature[i]) + ' K')
ax.set_xlabel('$B$ (T)')
ax.set_ylabel('$R_{xx}$ raw')
ax.legend()
plt.show()

# plot processed data
fig, ax = plt.subplots()
fig.suptitle('fig3d symmetrized data')
for i in indices:
    ax.plot(B_lin, Rxx_sym[:, i], label='T = ' + str(Temperature[i]) + ' K')
    ax.plot(B_lin, Rxx_sym[::-1, i], label='T = ' + str(Temperature[i]) + ' K')
ax.set_xlabel('$B$ (T)')
ax.set_ylabel('$R_{xx}$ symmetrized')
ax.legend()
plt.show()